const ErrorDecoratorFactory = (titleFontSize:number,title: string = "后盾人"):MethodDecorator => {
    return (target:Object, propertyKey:string | symbol,descriptor:PropertyDescriptor) => {
        const method = descriptor.value;
        descriptor.value = () => {
            try {
                method();
            } catch (error:any) {
                console.log(`%c${title}`,`color:green;font-size:${titleFontSize}px`);
                console.log(`%c${error.message}`,'color:red;font-size:16px;');
            }
        }
    }
}

class User{
    @ErrorDecoratorFactory(20)
    public find(){
        throw Error("用户查找失败")
    }

    @ErrorDecoratorFactory(20,"houdunren")
    public add(){
        throw Error("用户添加失败")
    }
}

const user = new User();
user.find();
user.add();
